package middleware

import (
	"github.com/gin-gonic/gin"
)

func Cross() gin.HandlerFunc {
	return func(c *gin.Context) {
		c.Header("Access-Control-Allow-Origin", "*")                                                                    // 允许访问所有域，可以换成具体url，注意仅具体url才能带cookie信息
		c.Header("Access-Control-Allow-Headers", "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token,x-token") //header的类型
		c.Header("Access-Control-Allow-Credentials", "true")                                                            //设置为true，允许ajax异步请求带cookie信息
		c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")                                     //允许请求方法

	}

}
